import sys

from PySide6.QtGui import QAction
from PySide6.QtWidgets import QApplication, QMainWindow,  QToolBar, QStatusBar, QVBoxLayout, QWidget, QPushButton

class Toolbox(QMainWindow):
    def __init__(self):
        super().__init__()

        # 设置窗口标题和初始大小
        self.setWindowTitle("工具箱窗体")
        self.setGeometry(100, 100, 800, 600)

        # 创建菜单栏
        menubar = self.menuBar()
        file_menu = menubar.addMenu('文件')

        # 添加菜单项
        new_action = QAction('新建', self)
        open_action = QAction('打开', self)
        file_menu.addAction(new_action)
        file_menu.addAction(open_action)

        # 创建工具栏
        toolbar = QToolBar('工具栏')
        self.addToolBar(toolbar)

        # 添加工具栏按钮
        new_button = QAction('新建', self)
        new_button.triggered.connect(self.show_message)
        toolbar.addAction(new_button)

        # 创建状态栏
        status_bar = QStatusBar()
        self.setStatusBar(status_bar)

        # 创建中心部件
        central_widget = QWidget()
        self.setCentralWidget(central_widget)

        # 创建布局并添加按钮
        layout = QVBoxLayout(central_widget)
        button = QPushButton('中心按钮', central_widget)
        layout.addWidget(button)

    def show_message(self):
        # 显示状态栏消息
        self.statusBar().showMessage('新建按钮被点击')

if __name__ == "__main__":
    app = QApplication(sys.argv)
    toolbox = Toolbox()
    toolbox.show()
    sys.exit(app.exec())